#include <ProcessThread/ProcessThread.h>
#include <IntExcept/IntExcept.h>

static void __fastcall FreeProcessResources(LPProcessControlBlock lpProcess, DWORD dwExitCode)
{
    KERNEL_ASSERT(lpProcess, "lpProcess is NULL\r\n");
    LPThreadControlBlock lpThread;
}

void __declspec(naked) SimpleExitProcess(DWORD dwExitCode)
{
    __asm
    {
        mov edx, [esp + 4] /* dwExitCode */
        mov edx, g_lpIntStack
        call GetCurrentCPUCore
        mov eax, [edx + eax * 4] /* g_lpIntStack[GetCurrentCPUCore()] */
        add eax, INT_STACK_SIZE /* top of int stack */
        mov esp, eax /* stack switch */
        mov ebp, eax
        call GetCurrentProcess /* current process to exit */
        mov ecx, eax /* fast call, lpProcess in ecx */
        call FreeProcessResources /* fast call, dwExitCode in edx */
    }
}